<?php

// TITLE: guestList
// FILE: guestList.php
// AUTHOR: dantira
// CREATED: Mar 21, 2015, 4:55:37 PM
?>

		public function createGuestList($eventId, $guestId, $status) {
			global $con;
			$sql = 'INSERT INTO guest_list (event_id, guest_id, status) VALUES (' . $eventId . ', ' . $guestId . ', ' . $status . ')';
			$this->open();
			$result = mysqli_query($con, $sql);
			$id = ($result) ? mysqli_insert_id($con) : $result;
			$this->close();
			return $id;
		}// end function

		public function readGuestList($id) {
			global $con;
			$sql = 'SELECT * FROM guest_list WHERE id = ' . $id;
			$this->open();
			$results = mysqli_query($con, $sql);
			$this->close();
			if ($results) {
				$result = mysqli_fetch_array($results);
				$guestList = new GuestList();
				$guestList->setEventId($this->readEvent($result[0]));
				$guestList->setGuestId($this->readGuest($result[1]));
				$guestList->setStatus($result[2]);
			} else {
				$guestList = false;
			}
			return $guestList;
		}// end function

		public function updateGuestList($eventId, $guestId, $status) {
			global $con;
			$sql = 'UPDATE guest_list SET event_id = ' . $event_id . ', guest_id = ' . $guestId . ', status = ' . $status . ' WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function deleteGuestList($id) {
			global $con;
			$sql = 'DELETE FROM guest_list WHERE event_id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function listGuestList() {
			global $con;
			$sql = 'SELECT * FROM guest_list';
			$this->open();
			$results = mysqli_query($con, $sql);
			$this->close();
			if ($results) {
				$guestLists = array();
				while ($result = mysqli_fetch_array($results)) {
					$guestList = new GuestList();
					$guestList->setEventId($this->readEvent($result[0]));
					$guestList->setGuestId($this->readGuest($result[1]));
					$guestList->setStatus($result[2]);
					$guestLists[] = $guestList;
				}// end while
			} else {
				$guestLists = false;
			}
			return $guestLists;
		}// end function

